package cn.spark.study.core;

/**
 * TODO
 *
 * @author jun.zhang6
 * @date 2020/11/6
 */
public class Test {
    public static void main(String[] args) {

        int[] arrays = {1, 3, 7, 4, 2};
        top3(arrays);

    }

    public static int[] top3(int[] arrays) {
        int[] top3 = new int[3];

        for (int i = 0; i < arrays.length; i++) {
            Integer e = arrays[i];

            for (int j = 0; j < top3.length; j++) {
                if (top3[j] == 0) {
                    top3[j] = e;
                    break;
                } else if (top3[j] < e) {
                    for (int k = 2; k > j; k--) {
                        top3[k] = top3[k - 1];
                    }
                    top3[j] = e;
                    break;
                }
            }
        }
        return top3;
    }
}
